package cz.vutbr.fit.xzemko01.tfmcbs.diagram.edit.parts;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Connection;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;

import cz.vutbr.fit.xzemko01.tfmcbs.diagram.edit.policies.RealizationItemSemanticEditPolicy;

/**
 * @generated
 */
public class RealizationEditPart extends ConnectionNodeEditPart implements
		ITreeBranchEditPart {

	/**
	 * @generated
	 */
	public static final int VISUAL_ID = 4003;

	/**
	 * @generated
	 */
	public RealizationEditPart(View view) {
		super(view);
	}

	/**
	 * @generated
	 */
	protected void createDefaultEditPolicies() {
		super.createDefaultEditPolicies();
		installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
				new RealizationItemSemanticEditPolicy());
	}

	/**
	 * Creates figure for this edit part.
	 * 
	 * Body of this method does not depend on settings in generation model
	 * so you may safely remove <i>generated</i> tag and modify it.
	 * 
	 * @generated
	 */

	protected Connection createConnectionFigure() {
		return new RealizationFigure();
	}

	/**
	 * @generated
	 */
	public RealizationFigure getPrimaryShape() {
		return (RealizationFigure) getFigure();
	}

	/**
	 * @generated
	 */
	public class RealizationFigure extends PolylineConnectionEx {

		/**
		 * @generated
		 */
		private WrappingLabel fFigureRealizationFigureName;

		/**
		 * @generated
		 */
		public RealizationFigure() {
			this.setForegroundColor(ColorConstants.black);

			createContents();
		}

		/**
		 * @generated
		 */
		private void createContents() {

			fFigureRealizationFigureName = new WrappingLabel();

			fFigureRealizationFigureName.setText("");

			fFigureRealizationFigureName
					.setFont(FFIGUREREALIZATIONFIGURENAME_FONT);

			this.add(fFigureRealizationFigureName);

		}

		/**
		 * @generated
		 */
		public WrappingLabel getFigureRealizationFigureName() {
			return fFigureRealizationFigureName;
		}

	}

	/**
	 * @generated
	 */
	static final Font FFIGUREREALIZATIONFIGURENAME_FONT = new Font(
			Display.getCurrent(), Display.getDefault().getSystemFont()
					.getFontData()[0].getName(), 9, SWT.BOLD);

}
